﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Model;
using BLL;
namespace ClassSystem
{
    public partial class ASPTeacherZuoye : System.Web.UI.Page
    {
        AchilveBLL bll = new AchilveBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Label1.Text = DateTime.Now.ToString();
            this.Repeater1.DataSource = bll.GetListAll(1,10);
            this.Repeater1.DataBind();

            if (!string.IsNullOrEmpty(Request["id"]))
            {
                int ID = Convert.ToInt32(Request["id"]);
                AchileModel PM = bll.GetListAll().Where(a => a.ID == ID).FirstOrDefault();
                if (PM.StudentAchilve >= 60)
                {
                    PM.StudentHG = "合格";
                }
                else
                {
                    PM.StudentHG = "不合格";
                }
                if (bll.Update(PM))
                {
                    Response.Redirect("ASPTeacherZuoye.aspx");
                }
                else
                {
                    Response.Write("<script>alert('修改失败！')</script>");
                }

            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string StudentNames = this.TextBox1.Text.Trim();
            int StudentIDs = Convert.ToInt32(this.TextBox2.Text.Trim());
            string StudentSubject = this.TextBox3.Text.Trim();
            List<AchileModel> list = bll.GetListAll().Where(a => a.StudentNames == StudentNames && a.StudentIDs == StudentIDs && a.StudentSubject == StudentSubject).ToList();
            if (list != null)
            {
                this.Repeater1.DataSource = list;
                this.Repeater1.DataBind();
            }
            if (list.Count == 0)
            {
                Response.Write("<script>alert('查询失败！')</script>");
            }
        }
    }
}